/* 
 * File:   CSString.h
 * Author: Muhammad Anis
 */

#ifndef CSSTRING_H
#define	CSSTRING_H

#include "../Utilities/boolean.h"

#define CSString char*

/**
 * Get Length of CSString
 * @param input CSString input
 * @return Length of CSString
 */
int GetCSStringLength(CSString input);

/**
 * Get character at specified position
 * @param text Input CSString
 * @param pos Position
 * @return Character at Position
 */
char GetCharAt(CSString text, int pos);

/**
 * Split Text Based on regex given
 * @param text Input text
 * @param regex output (array of string)
 */
int Split(CSString text,CSString* result, CSString regex);

/**
 * Get Substring of String from startIdx to lastIdx
 * @param input String input
 * @param startIdx Start index for substring
 * @param lastIdx End index for substring, if less than 0, start from end
 * @return Substring of String
 */
void CopyString(CSString input,CSString output,int startIdx, int lastIdx);

/**
 * Remove white spaces from start and end of text
 * @param input Input string
 * @return trimmed string
 */
char* Trim(char* input);
/**
 * Check if two string is equal
 * @param c1 First CSString
 * @param c2 Second CSString
 * @return true if c1=c2 case sensitive
 */
boolean EqCSString(CSString c1,CSString c2);

/**
 * Get index of pattern occurence in text
 * @param text Input text
 * @param pattern Pattern
 * @return first found index value
 */
int BMMatch(CSString text,CSString pattern);

/**
 * Create array of last occurence in array
 * @param pattern
 * @return 
 */
void BuildLast(CSString pattern,int* last);

/**
 * Get Min Value of two integer
 * @param a first value
 * @param b second value
 * @return the most minimal value between a and b
 */
int MinValue(int a,int b);

/**
 * Check if a character is white space
 * @param c character
 * @return  true if c is one of white spaces
 */
boolean IsSpace(char c);

/**
 * Dealocate char*
 * @param c char*
 */
void Dealocate(CSString c);

/**
 * Append String
 * @param first first string
 * @param second second string
 * @return first+second
 */
CSString AppendString(CSString first,CSString second);

#endif	/* CSSTRING_H */

